c# backend fix
[PxpRpc.git] / csharp / dotnet / pxprpc / BoundMethodCallable .cs
blob976d49ea532b919e57cb259d02658ed5fc926f23
1 using System;
2 using System.Collections.Generic;
3 using System.Reflection;
4 using System.Text;
6 namespace pxprpc
8 public class BoundMethodCallable : MethodCallable
10 protected Object boundObj;
11 public BoundMethodCallable(MethodInfo method, Object boundObj):base(method)
13 this.boundObj = boundObj;
15 public override void readParameter(PxpRequest req)
17 ServerContext c = req.context;
18 Object[] args = new Object[argList.Length];
19 if (firstInputParamIndex >= 1)
21 args[0] = null;
23 for (int i = firstInputParamIndex; i < argList.Length; i++)
25 args[i] = readNext(c, argList[i]);
27 req.parameter = new Object[] { null, args };
29 public override void call(PxpRequest req, Action<Object> asyncRet)
31 ServerContext ctx = req.context;
33 Object result = null;
34 Object[] args = (Object[])((Object[])req.parameter)[1];
35 if (firstInputParamIndex >= 1)
37 args[0] = asyncRet;
39 try
41 result = method.Invoke(this.boundObj, args);
42 if (firstInputParamIndex == 0)
44 asyncRet(result);
47 catch (Exception ex)
49 asyncRet(ex.InnerException);